#include "dialog_configworkgroupparas.h"
#include "ui_dialog_configworkgroupparas.h"
#include <QDebug>
#include "MessageBoxUtil.h"

Dialog_configWorkGroupParas::Dialog_configWorkGroupParas(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog_configWorkGroupParas)
{
    ui->setupUi(this);

    m_iniManager = new iniManager("config/workGroupConfig.ini");




    // 显示顶部相机镜头调焦的数值范围
    QString MinVal = QString::number(ui->spinBox_topCameraFoucs->minimum());
    QString MaxVal = QString::number(ui->spinBox_topCameraFoucs->maximum());
//    ui->label_topCameraFoucsOf1_minVal->setText(MinVal);
//    ui->label_topCameraFoucsOf1_maxVal->setText(MaxVal);


    // 显示顶部相机光源的数值范围
    MinVal = QString::number(ui->spinBox_topCameraLightValue->minimum());
    MaxVal = QString::number(ui->spinBox_topCameraLightValue->maximum());
//    ui->label_topCameraLightValueOf1_minVal->setText(MinVal);
//    ui->label_topCameraLightValueOf1_maxVal->setText(MaxVal);


    // 显示侧面相机镜头调焦的数值范围
    MinVal = QString::number(ui->spinBox_topCameraFoucs->minimum());
    MaxVal = QString::number(ui->spinBox_topCameraFoucs->maximum());
//    ui->label_topCameraFoucsOf2_minVal->setText(MinVal);
//    ui->label_topCameraFoucsOf2_maxVal->setText(MaxVal);

    // 显示侧面相机光源的数值范围
    MinVal = QString::number(ui->spinBox_topCameraLightValue->minimum());
    MaxVal = QString::number(ui->spinBox_topCameraLightValue->maximum());
//    ui->label_topCameraLightOf2_minVal->setText(MinVal);
//    ui->label_topCameraLightOf2_maxVal->setText(MaxVal);
    // 显示侧面相机底部补光光源的数值范围
    MinVal = QString::number(ui->spinBox_sideCameraFillLight->minimum());
    MaxVal = QString::number(ui->spinBox_sideCameraFillLight->maximum());
//    ui->label_sideCameraBottomLight_minVal->setText(MinVal);
//    ui->label_sideCameraBottomLight_maxVal->setText(MaxVal);


    // 显示侧面相机光源的数值范围
    MinVal = QString::number(ui->spinBox_bottomCameraLightValueOf2->minimum());
    MaxVal = QString::number(ui->spinBox_bottomCameraLightValueOf2->maximum());
//    ui->label_bottomCameraLightValueOf2_minVal->setText(MinVal);
//    ui->label_bottomCameraLightValueOf2_maxVal->setText(MaxVal);

    // QSpinBox设置为当前滑动条值  顶部调焦
    ui->hSlider_topCameraFoucs->setValue(ui->spinBox_topCameraFoucs->value());
    // 连接信号和槽
    connect(ui->hSlider_topCameraFoucs, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_topCameraFoucs->setValue(value);
    });
    connect(ui->spinBox_topCameraFoucs, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_topCameraFoucs, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_topCameraFoucs, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_topCameraFoucs->setValue(value);
    });
    connect(ui->spinBox_topCameraFoucs, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_topCameraFoucs, &QSlider::setValue);


    // QSpinBox设置为当前滑动条值  顶部光源
    ui->hSlider_topCameraLightValue->setValue(ui->spinBox_topCameraLightValue->value());
    // 连接信号和槽
    connect(ui->hSlider_topCameraLightValue, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_topCameraLightValue->setValue(value);
    });
    connect(ui->spinBox_topCameraLightValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_topCameraLightValue, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_topCameraLightValue, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_topCameraLightValue->setValue(value);
    });
    connect(ui->spinBox_topCameraLightValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_topCameraLightValue, &QSlider::setValue);


    // QSpinBox设置为当前滑动条值 侧面调焦 A
    ui->hSlider_sideCameraFoucsA->setValue(ui->spinBox_sideCameraFoucsA->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsA, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsA->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsA, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsA, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsA, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsA->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsA, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsA, &QSlider::setValue);




    // QSpinBox设置为当前滑动条值 侧面调焦 B
    ui->hSlider_sideCameraFoucsB->setValue(ui->spinBox_sideCameraFoucsB->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsB, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsB->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsB, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsB, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsB, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsB->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsB, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsB, &QSlider::setValue);




    // QSpinBox设置为当前滑动条值 侧面调焦 C
    ui->hSlider_sideCameraFoucsC->setValue(ui->spinBox_sideCameraFoucsC->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsC, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsC->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsC, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsC, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsC, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsC->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsC, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsC, &QSlider::setValue);




    // QSpinBox设置为当前滑动条值 侧面调焦 D
    ui->hSlider_sideCameraFoucsD->setValue(ui->spinBox_sideCameraFoucsD->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsD, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsD->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsD, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsD, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraFoucsD, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFoucsD->setValue(value);
    });
    connect(ui->spinBox_sideCameraFoucsD, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFoucsD, &QSlider::setValue);



    // QSpinBox设置为当前滑动条值  侧面光源
    ui->hSlider_sideCameraLightValue->setValue(ui->spinBox_sideCameraLightValue->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraLightValue, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraLightValue->setValue(value);
    });
    connect(ui->spinBox_sideCameraLightValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraLightValue, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraLightValue, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraLightValue->setValue(value);
    });
    connect(ui->spinBox_sideCameraLightValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraLightValue, &QSlider::setValue);




    // QSpinBox设置为当前滑动条值
    ui->hSlider_sideCameraFillLight->setValue(ui->spinBox_sideCameraFillLight->value());
    // 连接信号和槽
    connect(ui->hSlider_sideCameraFillLight, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFillLight->setValue(value);
    });
    connect(ui->spinBox_sideCameraFillLight, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFillLight, &QSlider::setValue);

    // 连接信号和槽
    connect(ui->hSlider_sideCameraFillLight, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_sideCameraFillLight->setValue(value);
    });
    connect(ui->spinBox_sideCameraFillLight, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_sideCameraFillLight, &QSlider::setValue);


    // QSpinBox设置为当前滑动条值
    ui->hSlider_bottomCameraLightValue->setValue(ui->spinBox_bottomCameraLightValueOf2->value());
    // 连接信号和槽
    connect(ui->hSlider_bottomCameraLightValue, &QSlider::valueChanged, this, [=](int value) {
        ui->spinBox_bottomCameraLightValueOf2->setValue(value);
    });
    connect(ui->spinBox_bottomCameraLightValueOf2, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
             ui->hSlider_bottomCameraLightValue, &QSlider::setValue);


    QRegExp regExp("^\\d+\\*\\d+\\*\\d+$"); // 正则表达式，匹配形如"L*H*G"的格式
    QValidator *validator = new QRegExpValidator(regExp, this);
    ui->LineEdit_size->setValidator(validator);
    // 连接槽
    connect(ui->LineEdit_size, &QLineEdit::textChanged, [=](QString str){

        if(str.isEmpty()){

            return;
        }

        QStringList str_list = str.split("*");

        if(str_list.size() != 3)
        {
            return;
        }

        ui->spinBox_L->setValue(str_list.at(0).toInt());
        ui->spinBox_W->setValue(str_list.at(1).toInt());
        ui->spinBox_H->setValue(str_list.at(2).toInt());

        if(ui->spinBox_L->value() == 450 && ui->spinBox_W->value() == 450)
        {
            ui->comboBox_chainWidth->setCurrentText("宽限位");
        } else if(ui->spinBox_L->value() == 220 && ui->spinBox_W->value() == 220){
            ui->comboBox_chainWidth->setCurrentText("窄限位");
        }
    });


    connect(ui->spinBox_L, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int val){
        QString str = ui->LineEdit_size->text();
        if(str.isEmpty()){

            return;
        }

        QStringList str_list = str.split("*");

        if(str_list.size() != 3)
        {
            return;
        }

        str_list[0] = QString::number(val);

        ui->LineEdit_size->setText(str_list.join("*"));

    });

    connect(ui->spinBox_W, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int val){
        QString str = ui->LineEdit_size->text();
        if(str.isEmpty()){

            return;
        }

        QStringList str_list = str.split("*");

        if(str_list.size() != 3)
        {
            return;
        }

        str_list[1] = QString::number(val);

        ui->LineEdit_size->setText(str_list.join("*"));

    });


    connect(ui->spinBox_H, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int val){
        QString str = ui->LineEdit_size->text();
        if(str.isEmpty()){

            return;
        }

        QStringList str_list = str.split("*");

        if(str_list.size() != 3)
        {
            return;
        }

        str_list[2] = QString::number(val);

        ui->LineEdit_size->setText(str_list.join("*"));

    });



    initData();


}

Dialog_configWorkGroupParas::~Dialog_configWorkGroupParas()
{
    delete ui;
    if(settings != nullptr)
        delete settings;
    if(m_iniManager != nullptr)
        delete m_iniManager;
}

void Dialog_configWorkGroupParas::initData()
{

    // 创建 QSettings 对象并加载 INI 文件
    settings = new QSettings("config/workGroupConfig.ini", QSettings::IniFormat);

    // 获取所有的组
    groups = m_iniManager->allGroups();
    groups.removeOne("current");
    groups.removeOne("other");
    groups.removeOne("template");


    if (groups.isEmpty()) {
        qDebug() << "No groups found in the INI file.";
    } else {
        // 初始化当前组索引
        currentGroupIndex = m_iniManager->readValue("current", "group").toInt();

        currentGroup = m_iniManager->readValue(QString::number(currentGroupIndex), "name").toString();
        qDebug() << "Current group:" << currentGroup;

        // 设置组上限索引
        maxGroupIndex = groups.size() - 1;
        m_iniManager->writeValue("current", "count", groups.size());

        QStringList currentGroupIdList = iniManager::splitString(currentGroup);
        if(currentGroupIdList.isEmpty())
        {
            qDebug() << "工作组编号，拆分错误";
            if(MessageBoxUtil::Ok == MessageBoxUtil::showMessage(this, MessageBoxUtil::Warning, "警告", QString("工作组：%1 格式不正确!").arg(currentGroup), MessageBoxUtil::Ok))
            {

            }
            return;
        }

        QString currGroupId = currentGroupIdList.at(0);

        ui->LineEdit_workGroupName->setText(m_iniManager->readValue(currGroupId,"name").toString());
        ui->LineEdit_size->setText(m_iniManager->readValue(currGroupId,"size").toString());
//        ui->comboBox_chainWidth->currentText(m_iniManager->readValue(currGroupId, "type").toString());
        ui->hSlider_topCameraFoucs->setValue(m_iniManager->readValue(currGroupId,"topCamFocusVal").toInt());
        ui->hSlider_topCameraLightValue->setValue(m_iniManager->readValue(currGroupId,"topLightVale").toInt());

        ui->hSlider_sideCameraFoucsA->setValue(m_iniManager->readValue(currGroupId,"sideCamFocusVal_A").toInt());
        ui->hSlider_sideCameraFoucsB->setValue(m_iniManager->readValue(currGroupId,"sideCamFocusVal_B").toInt());
        ui->hSlider_sideCameraFoucsC->setValue(m_iniManager->readValue(currGroupId,"sideCamFocusVal_C").toInt());
        ui->hSlider_sideCameraFoucsD->setValue(m_iniManager->readValue(currGroupId,"sideCamFocusVal_D").toInt());
        ui->hSlider_sideCameraLightValue->setValue(m_iniManager->readValue(currGroupId,"sideLightVal").toInt());
        ui->hSlider_sideCameraFillLight->setValue(m_iniManager->readValue(currGroupId,"sideFillLightVal").toInt());

        ui->hSlider_bottomCameraLightValue->setValue(m_iniManager->readValue(currGroupId,"bottomLightVal").toInt());
    }
}

void Dialog_configWorkGroupParas::savePara()
{
    QString name  = ui->LineEdit_workGroupName->text();

    QStringList currentGroupIdList = iniManager::splitString(name);
    if(currentGroupIdList.isEmpty())
    {
        qDebug() << "工作组编号，拆分错误";
        if(MessageBoxUtil::Ok == MessageBoxUtil::showMessage(this, MessageBoxUtil::Warning, "警告", QString("工作组：%1 格式不正确!").arg(name), MessageBoxUtil::Ok))
        {

        }
        return;
    }

    QString size = ui->LineEdit_size->text();
    int topCamFocusVal      = ui->hSlider_topCameraFoucs->value();
    int topLightVale        = ui->hSlider_topCameraLightValue->value();
    int sideCamFocusVal_A   = ui->hSlider_sideCameraFoucsA->value();
    int sideCamFocusVal_B   = ui->hSlider_sideCameraFoucsB->value();
    int sideCamFocusVal_C   = ui->hSlider_sideCameraFoucsC->value();
    int sideCamFocusVal_D   = ui->hSlider_sideCameraFoucsD->value();
    int sideLightVal        = ui->hSlider_sideCameraLightValue->value();
    int sideFillLightVal    = ui->hSlider_sideCameraFillLight->value();
    int bottomLightVal      = ui->hSlider_bottomCameraLightValue->value();


    settings->beginGroup(currentGroupIdList.at(0));
    settings->setValue("name", name);
    settings->setValue("size", size);
    settings->setValue("topCamFocusVal", topCamFocusVal);
    settings->setValue("topLightVale", topLightVale);
    settings->setValue("sideCamFocusVal_A", sideCamFocusVal_A);
    settings->setValue("sideCamFocusVal_B", sideCamFocusVal_B);
    settings->setValue("sideCamFocusVal_C", sideCamFocusVal_C);
    settings->setValue("sideCamFocusVal_D", sideCamFocusVal_D);
    settings->setValue("sideLightVal", sideLightVal);
    settings->setValue("sideFillLightVal", sideFillLightVal);
    settings->setValue("bottomLightVal", bottomLightVal);
    settings->endGroup();

    // 设置当前组
    settings->beginGroup("current");
    settings->setValue("group", name);

    // 确保更改立即保存到文件中
    settings->sync();
}
void Dialog_configWorkGroupParas::loatPara()
{

}

void Dialog_configWorkGroupParas::on_btn_save_clicked()
{
    QString name  = ui->LineEdit_workGroupName->text();

//    if(m_iniManager->isExists("name", name))
//    {
//        if(MessageBoxUtil::Ok == MessageBoxUtil::showMessage(this, MessageBoxUtil::Warning, "提示", QString("工作组：%1 已存在，请勿重复添加!").arg(name), MessageBoxUtil::Ok))
//        {

//        }
//        return;
//    }

    savePara();
    accept();
}


void Dialog_configWorkGroupParas::on_btn_cancel_clicked()
{
    reject();
}


void Dialog_configWorkGroupParas::on_btn_next_clicked()
{
    if (currentGroupIndex < maxGroupIndex) {
        currentGroupIndex++;
    } else {
        currentGroupIndex = 0; // 循环到第一个组
    }
    currentGroup = groups[currentGroupIndex];
    qDebug() << "Current group:" << currentGroup;

    ui->LineEdit_workGroupName->setText(m_iniManager->readValue(currentGroup,"name").toString());
    ui->LineEdit_size->setText(m_iniManager->readValue(currentGroup,"size").toString());
//        ui->comboBox_chainWidth->currentText(m_iniManager->readValue(currentGroup, "type").toString());
    ui->hSlider_topCameraFoucs->setValue(m_iniManager->readValue(currentGroup,"topCamFocusVal").toInt());
    ui->hSlider_topCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"topLightVale").toInt());

    ui->hSlider_sideCameraFoucsA->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_A").toInt());
    ui->hSlider_sideCameraFoucsB->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_B").toInt());
    ui->hSlider_sideCameraFoucsC->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_C").toInt());
    ui->hSlider_sideCameraFoucsD->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_D").toInt());
    ui->hSlider_sideCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"sideLightVal").toInt());
    ui->hSlider_sideCameraFillLight->setValue(m_iniManager->readValue(currentGroup,"sideFillLightVal").toInt());

    ui->hSlider_bottomCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"bottomLightVal").toInt());
}


void Dialog_configWorkGroupParas::on_btn_pre_clicked()
{
    if (currentGroupIndex > 0) {
        currentGroupIndex--;
    } else {
        currentGroupIndex = maxGroupIndex; // 循环到最后一个组
    }
    currentGroup = groups[currentGroupIndex];
    qDebug() << "Current group:" << currentGroup;
    ui->LineEdit_workGroupName->setText(m_iniManager->readValue(currentGroup,"name").toString());
    ui->LineEdit_size->setText(m_iniManager->readValue(currentGroup,"size").toString());
//        ui->comboBox_chainWidth->currentText(m_iniManager->readValue(currentGroup, "type").toString());
    ui->hSlider_topCameraFoucs->setValue(m_iniManager->readValue(currentGroup,"topCamFocusVal").toInt());
    ui->hSlider_topCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"topLightVale").toInt());

    ui->hSlider_sideCameraFoucsA->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_A").toInt());
    ui->hSlider_sideCameraFoucsB->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_B").toInt());
    ui->hSlider_sideCameraFoucsC->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_C").toInt());
    ui->hSlider_sideCameraFoucsD->setValue(m_iniManager->readValue(currentGroup,"sideCamFocusVal_D").toInt());
    ui->hSlider_sideCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"sideLightVal").toInt());
    ui->hSlider_sideCameraFillLight->setValue(m_iniManager->readValue(currentGroup,"sideFillLightVal").toInt());

    ui->hSlider_bottomCameraLightValue->setValue(m_iniManager->readValue(currentGroup,"bottomLightVal").toInt());
}


void Dialog_configWorkGroupParas::on_btn_addNewGroup_clicked()
{
//    QString name  = ui->LineEdit_workGroupName->text();

//    QString size = ui->LineEdit_size->text();
//    int top_cam_focusRing_value_1 = ui->hSlider_topCameraFoucs->value();
//    int top_cam_lightValue_1 = ui->hSlider_topCameraLightValue->value();
//    int top_cam_focusRing_value_2 = ui->hSlider_topCameraFoucs->value();
//    int top_cam_lightValue_2 = ui->hSlider_topCameraLightValue->value();
//    int sideCameraBottomLight = ui->hSlider_sideCameraFillLight->value();
//    int bottom_cam_lightValue_2 = ui->hSlider_bottomCameraLightValue->value();


//    QStringList idList = name.split("group");

//    if(idList.size() < 2)
//    {
//        qDebug() << "工作组分割有问题！";
//        return;
//    }

//    QString group_L = QString::number(ui->spinBox_L->value());
//    QString group_W = QString::number(ui->spinBox_W->value());
//    QString group_H = QString::number(ui->spinBox_H->value());

//    QString group_type = (ui->comboBox_chainWidth->currentText() == "宽限位") ? "K" : "Z";

//    QString groupName = idList.at(1) + "_" + group_L + "_" + group_W + "_" + group_H + "_" + group_type;


//    settings->beginGroup(name);
//    settings->setValue("name", groupName);
//    settings->setValue("size", size);
//    settings->setValue("top_cam_focusRing_value_1", top_cam_focusRing_value_1);
//    settings->setValue("top_cam_lightValue_1", top_cam_lightValue_1);
//    settings->setValue("side_cam_focusRing_value_2", top_cam_focusRing_value_2);
//    settings->setValue("side_cam_lightValue_1", top_cam_lightValue_2);
//    settings->setValue("side_cam_fillLight", sideCameraBottomLight);
//    settings->setValue("bottom_cam_lightValue_2", bottom_cam_lightValue_2);
//    settings->endGroup();

//    // 设置当前组
//    settings->beginGroup("current");
//    settings->setValue("group", name);

//    // 确保更改立即保存到文件中
//    settings->sync();
}
